package com.yuandian.management.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuandian.bpm.common.core.util.R;
import com.yuandian.bpm.common.log.annotation.SysLog;
import com.yuandian.api.management.entity.ConfIndexExtractRule;
import com.yuandian.management.service.ConfIndexExtractRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import com.yuandian.bpm.common.excel.annotation.ResponseExcel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import java.util.List;

 /**
 * 指标提取规则-Controller
 * @author zfsn
 * @date 2023-8-4
 */
@Api(tags = "指标提取规则功能接口")
@RestController
@RequestMapping("/indexExtractRule")
public class ConfIndexExtractRuleController {

    @Autowired
    private ConfIndexExtractRuleService service;

	@GetMapping("/{resourceCode}")
	public R<List<ConfIndexExtractRule>> queryIndexExtractRules(@PathVariable(value = "resourceCode") String resourceCode) {
		List<ConfIndexExtractRule> resultList = service.list(new LambdaQueryWrapper<ConfIndexExtractRule>()
				.eq(ConfIndexExtractRule::getResourceCode, resourceCode)
				.eq(ConfIndexExtractRule::getIsDel, 0));
		return R.ok(resultList);
	}

    /** 
     * 新增数据
     * @param confIndexExtractRuleList 实例对象
     * @return 通用返回对象
     */
    @ApiOperation(value = "新增数据", notes = "新增数据")
    @SysLog("新增指标提取规则数据")
    @PostMapping
    public R<Boolean> save(@RequestBody List<ConfIndexExtractRule> confIndexExtractRuleList) {
        return R.ok(service.insertIndexExtractRules(confIndexExtractRuleList));
    }
    

}